package com.hj.springframework2.handler;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @Author : hujing
 * @Date: 2025/6/24 10:27
 * @Description:
 */
public class LoggingInvocationHandler implements InvocationHandler {
    
    private final Object target;
    
    public LoggingInvocationHandler(Object target){
        this.target = target;
    }
    
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before method:"+method.getName());
        Object result = method.invoke(target, args);
        System.out.println("after method:"+method.getName());
        return result;
    }
}
